package udp

import "encoding/xml"

//*********************************配置文件解析config.xml*********************************
//用于解析配置文件中的XML文件
type XMLConfigInfo struct {
	XMLName     xml.Name `xml:"LocalCfg"`
	Param       paramInfo
	AddressMap  addressMapInfo
	DasInfoData dasInfo
}

type paramInfo struct {
	XMLName               xml.Name `xml:"Param"`
	LogPath               string   `xml:"LogPath"`
	LogLevel              int64    `xml:"LogLevel"`
	LogAutoDel            bool     `xml:"LogAutoDel"`
	KeepAliveSeconds      int64    `xml:"KeepAliveSeconds"`
	KeepAliveCount        int64    `xml:"KeepAliveCount"`
	AlarmServerType       int64    `xml:"AlarmServerType"`
	AlarmServerIP         string   `xml:"AlarmServerIP"`
	AlarmServerUdpPort    int64    `xml:"AlarmServerUdpPort"`
	AlarmServerTcpPort    int64    `xml:"AlarmServerTcpPort"`
	AlarmServerMqttPort   int64    `xml:"AlarmServerMqttPort"`
	AlarmServerPortUseCms int64    `xml:"AlarmServerPortUseCms"`
	NTPServerIP           string   `xml:"NTPServerIP"`
	NTPServerPort         int64    `xml:"NTPServerPort"`
	NTPInterval           int64    `xml:"NTPInterval"`
	PictureServerType     int64    `xml:"PictureServerType"`
	PictureServerIP       string   `xml:"PictureServerIP"`
	PictureServerPort     int64    `xml:"PictureServerPort"`
	CmsAccessSecurity     int64    `xml:"CmsAccessSecurity"`
	AlarmAccessSecurity   int64    `xml:"AlarmAccessSecurity"`
	StreamAccessSecurity  int64    `xml:"StreamAccessSecurity"`
	AlarmPictureSeparate  int64    `xml:"AlarmPictureSeparate"`
}

type addressMapInfo struct {
	XMLName             xml.Name `xml:"AddressMap"`
	Enable              int64    `xml:"Enable"`
	StreamServerIP      string   `xml:"StreamServerIP"`
	StreamServerPort    int64    `xml:"StreamServerPort"`
	AudioServerIP       string   `xml:"AudioServerIP"`
	AudioServerPort     int64    `xml:"AudioServerPort"`
	AlarmServerIP       string   `xml:"AlarmServerIP"`
	AlarmServerUdpPort  int64    `xml:"AlarmServerUdpPort"`
	AlarmServerTcpPort  int64    `xml:"AlarmServerTcpPort"`
	AlarmServerMqttPort int64    `xml:"AlarmServerMqttPort"`
	PictureServerIP     string   `xml:"PictureServerIP"`
	PictureServerPort   int64    `xml:"PictureServerPort"`
}

type dasInfo struct {
	XMLName     xml.Name `xml:"DasInfo"`
	ServerType  int64    `xml:"ServerType"`
	DasInfoPath string   `xml:"DasInfoPath"`
	DASIP       string   `xml:"DASIP"`
	DASPort     int64    `xml:"DASPort"`
}

//*********************************处理UDP信令*********************************
//EHome XML基础通信协议，用于解析UDP服务器接收的来自UDP客户端（EHome设备）的信息
type xmlBasePacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`  //REQUEST Or RESPONSE
	Command      string   `xml:"Command"`      //REQUEST时使用此字段，UDP客户端（EHome设备）请求信令
	WhichCommand string   `xml:"WhichCommand"` //RESPONSE时使用此字段，UDP客户端（EHome设备）回复信令
}

//UDP客户端 ---> UDP服务端：注册请求
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>37173</Sequence>
<CommandType>REQUEST</CommandType>
<Command>REGISTER</Command>
<Params>
<NetUnitType>PU</NetUnitType> //保留内容
<DeviceID>D53257168</DeviceID> //设备ID
<FirmwareVersion>V3.5.38 build 191215</FirmwareVersion> //固件版本信息
<LocalIP>192.168.1.227</LocalIP> //设备IP地址
<LocalPort>9511</LocalPort> //设备端口
<DevType>90</DevType> //设备类型：1-数字视频录像机，3-数字视频服务器，30-网络摄像机，40-网络球机，此处90不知道具体设备类型
<Manufacture>0</Manufacture> //制造商代码
</Params>
</PPVSPMessage>
*/
type requestRegisterPacket struct {
	XMLName         xml.Name `xml:"PPVSPMessage"`
	Version         float64  `xml:"Version"`     //请求的版本目前都是2.0
	Sequence        int64    `xml:"Sequence"`    //来自设备的请求序列号，回复时需要保持一致
	CommandType     string   `xml:"CommandType"` //REQUEST
	Command         string   `xml:"Command"`
	NetUnitType     string   `xml:"Params>NetUnitType"`
	DeviceID        string   `xml:"Params>DeviceID"`
	FirmwareVersion string   `xml:"Params>FirmwareVersion"`
	LocalIP         string   `xml:"Params>LocalIP"`
	LocalPort       int64    `xml:"Params>LocalPort"`
	DevType         int64    `xml:"Params>DevType"`
	Manufacture     int64    `xml:"Params>Manufacture"`
}

//UDP服务端 ---> UDP客户端：回复注册请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>37173</Sequence>
<CommandType>RESPONSE</CommandType>
<Method>REGISTER</Method>
<WhichCommand>REGISTER</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
    <KeepAliveSeconds>15</KeepAliveSeconds>
    <AlarmServerIP>192.168.1.243</AlarmServerIP>
    <AlarmServerPort>7332</AlarmServerPort>
    <AlarmServerType>2</AlarmServerType>
    <NTPServerIP>10.17.132.231</NTPServerIP>
    <NTPServerPort>123</NTPServerPort>
    <NTPInterval>3600</NTPInterval>
    <PictureServer>192.168.1.243</PictureServer>
    <PictureServerPort>10009</PictureServerPort>
    <PictureServerType>2</PictureServerType>
    <BlackListAddr></BlackListAddr>
    <BlackListName></BlackListName>
    <BlackListPort>0</BlackListPort>
    <BlackListUser></BlackListUser>
    <BlackListPassword></BlackListPassword>
    <RegisterServerIP></RegisterServerIP>
    <RegisterServerPort>0</RegisterServerPort>
</Params>
</PPVSPMessage>
*/
type responseRegisterPacket struct {
	XMLName            xml.Name `xml:"PPVSPMessage"`
	Version            float64  `xml:"Version"`     //回复的版本目前都是2.5
	Sequence           int64    `xml:"Sequence"`    //和对应的请求序列号需保持一致
	CommandType        string   `xml:"CommandType"` //RESPONSE
	Method             string   `xml:"Method"`
	WhichCommand       string   `xml:"WhichCommand"`
	Status             int64    `xml:"Status"`
	Description        string   `xml:"Description"`
	KeepAliveSeconds   int64    `xml:"Params>KeepAliveSeconds"`
	AlarmServerIP      string   `xml:"Params>AlarmServerIP"`
	AlarmServerPort    int64    `xml:"Params>AlarmServerPort"`
	AlarmServerType    int64    `xml:"Params>AlarmServerType"`
	NTPServerIP        string   `xml:"Params>NTPServerIP"`
	NTPServerPort      int64    `xml:"Params>NTPServerPort"`
	NTPInterval        int64    `xml:"Params>NTPInterval"`
	PictureServer      string   `xml:"Params>PictureServer"`
	PictureServerPort  int64    `xml:"Params>PictureServerPort"`
	PictureServerType  int64    `xml:"Params>PictureServerType"`
	BlackListAddr      string   `xml:"Params>BlackListAddr"`
	BlackListName      string   `xml:"Params>BlackListName"`
	BlackListPort      int64    `xml:"Params>BlackListPort"`
	BlackListUser      string   `xml:"Params>BlackListUser"`
	BlackListPassword  string   `xml:"Params>BlackListPassword"`
	RegisterServerIP   string   `xml:"Params>RegisterServerIP"`
	RegisterServerPort int64    `xml:"Params>RegisterServerPort"`
}

//UDP客户端 ---> UDP服务端：保活请求
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>37174</Sequence>
<CommandType>REQUEST</CommandType>
<Command>KEEPALIVE</Command>
<Params>
<DeviceID>D53257168</DeviceID>
</Params>
</PPVSPMessage>
*/
type requestKeepalivePacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Command     string   `xml:"Command"`
	DeviceID    string   `xml:"Params>DeviceID"`
}

//UDP服务端 ---> UDP客户端：回复保活请求
/*
设备已注册，回复下面内容：
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>37174</Sequence>
<CommandType>RESPONSE</CommandType>
<Method>CONTROL</Method>
<WhichCommand>KEEPALIVE</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
</PPVSPMessage>

设备未注册，回复下面内容：
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>37174</Sequence>
<CommandType>RESPONSE</CommandType>
<Method>REGISTER</Method>
<WhichCommand>KEEPALIVE</WhichCommand>
<Status>403</Status>
<Description>OK</Description>
</PPVSPMessage>
*/
type responseKeepalivePacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	Method       string   `xml:"Method"`
	WhichCommand string   `xml:"WhichCommand"`
	Status       int64    `xml:"Status"`
	Description  string   `xml:"Description"`
}

//UDP服务端 ---> UDP客户端：获取设备配置信息请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>6846</Sequence>
<CommandType>REQUEST</CommandType>
<Method>PARAM</Method>
<Command>GETDEVICECONFIG</Command>
<Params>
    <ConfigCmd>GetServerInfo</ConfigCmd>
    <ConfigParam1>0</ConfigParam1>
    <ConfigParam2>0</ConfigParam2>
    <ConfigParam3>0</ConfigParam3>
    <ConfigParam4>0</ConfigParam4>
</Params>
</PPVSPMessage>
*/
type requestGetServerInfoPacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"` //请求的版本目前都是2.0
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	Method       string   `xml:"Method"`
	Command      string   `xml:"Command"`
	ConfigCmd    string   `xml:"Params>ConfigCmd"`
	ConfigParam1 int64    `xml:"Params>ConfigParam1"`
	ConfigParam2 int64    `xml:"Params>ConfigParam2"`
	ConfigParam3 int64    `xml:"Params>ConfigParam3"`
	ConfigParam4 int64    `xml:"Params>ConfigParam4"`
}

//UDP客户端 ---> UDP服务端：设备配置信息回复
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>6846</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>GETDEVICECONFIG</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
<ConfigXML>
<SERVERINFO>
<ChannelNumber>4</ChannelNumber>
<ChannelAmount>9</ChannelAmount>
<DVRType>90</DVRType>
<DiskNumber>1</DiskNumber>
<SerialNumber>0420190822CCCHD53257168WCVU</SerialNumber>
<AlarmInPortNum>4</AlarmInPortNum>
<AlarmInAmount>6</AlarmInAmount>
<AlarmOutPortNum>4</AlarmOutPortNum>
<AlarmOutAmount>6</AlarmOutAmount>
<StartChannel>1</StartChannel>
<AudioChanNum>1</AudioChanNum>
<MaxDigitChannelNum>5</MaxDigitChannelNum>
<AudioEncType>1</AudioEncType>
<SupportZeroChan>1</SupportZeroChan>
</SERVERINFO>
</ConfigXML>
</Params>
</PPVSPMessage>
*/
type responseGetServerInfoPacket struct {
	XMLName            xml.Name `xml:"PPVSPMessage"`
	Version            float64  `xml:"Version"`
	Sequence           int64    `xml:"Sequence"`
	CommandType        string   `xml:"CommandType"`
	WhichCommand       string   `xml:"WhichCommand"`
	Status             int64    `xml:"Status"`
	Description        string   `xml:"Description"`
	ChannelNumber      int64    `xml:"Params>ConfigXML>SERVERINFO>ChannelNumber"`
	ChannelAmount      int64    `xml:"Params>ConfigXML>SERVERINFO>ChannelAmount"`
	DVRType            int64    `xml:"Params>ConfigXML>SERVERINFO>DVRType"`
	DiskNumber         int64    `xml:"Params>ConfigXML>SERVERINFO>DiskNumber"`
	SerialNumber       string   `xml:"Params>ConfigXML>SERVERINFO>SerialNumber"`
	AlarmInPortNum     int64    `xml:"Params>ConfigXML>SERVERINFO>AlarmInPortNum"`
	AlarmInAmount      int64    `xml:"Params>ConfigXML>SERVERINFO>AlarmInAmount"`
	AlarmOutPortNum    int64    `xml:"Params>ConfigXML>SERVERINFO>AlarmOutPortNum"`
	AlarmOutAmount     int64    `xml:"Params>ConfigXML>SERVERINFO>AlarmOutAmount"`
	StartChannel       int64    `xml:"Params>ConfigXML>SERVERINFO>StartChannel"`
	AudioChanNum       int64    `xml:"Params>ConfigXML>SERVERINFO>AudioChanNum"`
	MaxDigitChannelNum int64    `xml:"Params>ConfigXML>SERVERINFO>MaxDigitChannelNum"`
	AudioEncType       int64    `xml:"Params>ConfigXML>SERVERINFO>AudioEncType"`
	SmartType          int64    `xml:"Params>ConfigXML>SERVERINFO>SmartType"`
	StartChan          int64    `xml:"Params>ConfigXML>SERVERINFO>StartChan"`
	StartDChan         int64    `xml:"Params>ConfigXML>SERVERINFO>StartDChan"`
}

//UDP服务端 ---> UDP客户端：设备工作状态信息请求，主要是获取通道列表
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
    <Version>4.0</Version>
    <Sequence>5282</Sequence>
    <CommandType>REQUEST</CommandType>
    <Method>QUERY</Method>
    <Command>GETDEVICEWORKSTATUS</Command>
    <Params />
</PPVSPMessage>
*/
type requestGetDeviceWorkStatusPacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Method      string   `xml:"Method"`
	Command     string   `xml:"Command"`
	Params      struct{} `xml:"Params"`
}

//UDP客户端 ---> UDP服务端：设备工作状态信息回复
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>5282</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>GETDEVICEWORKSTATUS</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
<DeviceStatusXML>
<Run>0</Run>
<CPU>5</CPU>
<Mem>57</Mem>
<DSKStatus>
<DSK>1-476940-202752-0</DSK>
</DSKStatus>
<CHStatus>
<CH>1-1-1-1-111-0</CH>
<CH>2-1-1-1-45-0</CH>
<CH>3-1-1-1-46-0</CH>
<CH>4-0-1-1-0-0</CH>
<CH>5-0-0-0-0-0</CH>
<CH>6-1-0-0-0-0</CH>
</CHStatus>
<AlarmInStatus/>
<AlarmOutStatus/>
<LocalDisplayStatus>0</LocalDisplayStatus>
<Remark>test/debug</Remark>
</DeviceStatusXML>
</Params>
</PPVSPMessage>
*/
type responseGetDeviceWorkStatusPacket struct {
	XMLName            xml.Name `xml:"PPVSPMessage"`
	Version            float64  `xml:"Version"`
	Sequence           int64    `xml:"Sequence"`
	CommandType        string   `xml:"CommandType"`
	WhichCommand       string   `xml:"WhichCommand"`
	Status             string   `xml:"Status"`
	Description        string   `xml:"Description"`
	Run                int64    `xml:"Params>DeviceStatusXML>Run"`                //设备状态：0-正常，1-CPU使用率过高（高于85%），2-硬件错误
	CPU                int64    `xml:"Params>DeviceStatusXML>CPU"`                //CPU使用率，取值范围为0%到100%
	Mem                int64    `xml:"Params>DeviceStatusXML>Mem"`                //内存使用率，取值范围为0%到100%
	DSKStatus          dskList  `xml:"Params>DeviceStatusXML>DSKStatus"`          //包含多个参数的字符串，包括硬盘号，硬盘容量（单位：MB），硬盘剩余空间（单位：MB），和硬盘状态（0-活跃，1-睡眠，2-异常）；每个参数由“-”分隔
	CHStatus           chList   `xml:"Params>DeviceStatusXML>CHStatus"`           //包含多个参数的字符串，包括通道号，录像状态（0-停止，1-开始），视频信号状态（0-正常，1-视频丢失），通道编码状态（0-正常，1-异常），实际码率（单位：Kbps），关联客户端数量
	AlarmInStatus      string   `xml:"Params>DeviceStatusXML>AlarmInStatus"`      //已启用报警输入号，多个号之间用逗号隔开
	AlarmOutStatus     string   `xml:"Params>DeviceStatusXML>AlarmOutStatus"`     //已启用报警输出号，多个号之间用逗号隔开
	LocalDisplayStatus int64    `xml:"Params>DeviceStatusXML>LocalDisplayStatus"` //本地显示状态：0-正常，1-异常
	Remark             string   `xml:"Params>DeviceStatusXML>Remark"`
}

type chList struct {
	CHList []string `xml:"CH"`
}

type dskList struct {
	DSKList []string `xml:"DSK"`
}

//UDP服务端 ---> UDP客户端：实时直播启动请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>8066</Sequence>
<CommandType>REQUEST</CommandType>
<Method>MEDIA</Method>
<Command>INVITESTREAM</Command>
<Params>
    <Channel>1</Channel>
    <ChannelType>MAIN</ChannelType> //主码流：MAIN；子码流：SUB；三码流：THIRD
    <SinkIP>192.168.1.133</SinkIP> //在app.conf配置文件中
    <SinkPort>8000</SinkPort> //在app.conf配置文件中
</Params>
</PPVSPMessage>
*/
type requestInviteStreamPacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Method      string   `xml:"Method"`
	Command     string   `xml:"Command"`
	Channel     int64    `xml:"Params>Channel"`     //通道ID
	ChannelType string   `xml:"Params>ChannelType"` //码流类型
	SinkIP      string   `xml:"Params>SinkIP"`
	SinkPort    int64    `xml:"Params>SinkPort"`
}

//UDP客户端 ---> UDP服务端：实时直播启动回复
/*
实时直播启动成功：
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>8066</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>INVITESTREAM</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
<Session>679647373</Session>
</Params>
</PPVSPMessage>

实时直播启动失败：
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>8066</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>INVITESTREAM</WhichCommand>
<Status>401</Status> //TCP服务器推流失败
<Description>Unknow Err Code.</Description>
<Params/>
</PPVSPMessage>
*/
type responseInviteStreamPacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	WhichCommand string   `xml:"WhichCommand"`
	Status       int64    `xml:"Status"`
	Description  string   `xml:"Description"`
	Session      string   `xml:"Params>Session"` //成功了会生成session，关闭实时直播时使用
}

//UDP服务端 ---> UDP客户端：实时直播关闭请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>8068</Sequence>
<CommandType>REQUEST</CommandType>
<Method>MEDIA</Method>
<Command>BYESTREAM</Command>
<Params>
    <Session>679647373</Session>
</Params>
</PPVSPMessage>
*/
type requestByeStreamPacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Method      string   `xml:"Method"`
	Command     string   `xml:"Command"`
	Session     string   `xml:"Params>Session"`
}

//UDP客户端 ---> UDP服务端：实时直播关闭回复
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>8068</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>BYESTREAM</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
<Session>679647373</Session>
</Params>
</PPVSPMessage>
*/
type responseByeStreamPacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	WhichCommand string   `xml:"WhichCommand"`
	Status       int64    `xml:"Status"`
	Description  string   `xml:"Description"`
	Session      string   `xml:"Params>Session"`
}

//UDP服务端 ---> UDP客户端：查询指定通道录像文件请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>1778</Sequence>
<CommandType>REQUEST</CommandType>
<Method>QUERY</Method>
<Command>QUERYRECORDEDFILES</Command>
<Params>
    <Channel>1</Channel> //通道ID
    <FileType>255</FileType> //录像类型
    <StartTime>2021-02-02 00:00:00</StartTime> //开始时间
    <StopTime>2021-02-02 23:59:59</StopTime> //结束时间
    <ChunkSize>8</ChunkSize>
    <StartIdx>0</StartIdx>
</Params>
</PPVSPMessage>
录像类型定义如下：
全部 ---> 255  定时录像 ---> 0  移动侦测 ---> 1  报警触发 ---> 2  报警|动测 ---> 3  报警&动测 ---> 4
命令触发 ---> 5  手动录像 ---> 6  震动报警 ---> 7  环境报警 ---> 8  智能报警 ---> 9  PIR报警 ---> 10
无线报警 ---> 11  呼救报警 ---> 12  全部报警录像 ---> 13  车牌识别图 ---> 101  稽查报警图 ---> 102
手动抓拍图 ---> 103  回放抓拍图 ---> 104
*/
type requestQueryRecordedFilesPacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Method      string   `xml:"Method"`
	Command     string   `xml:"Command"`
	Channel     int64    `xml:"Params>Channel"`   //通道ID
	FileType    int64    `xml:"Params>FileType"`  //录像文件查询类型
	StartTime   string   `xml:"Params>StartTime"` //开始时间
	StopTime    string   `xml:"Params>StopTime"`  //结束时间
	ChunkSize   int64    `xml:"Params>ChunkSize"`
	StartIdx    int64    `xml:"Params>StartIdx"`
}

//UDP服务端 ---> UDP客户端：云台控制
//<?xml version="1.0" encoding="GB2312" ?>
//<PPVSPMessage>
//<Version>2.5</Version>
//<Sequence>6256</Sequence>
//<CommandType>REQUEST</CommandType>
//<Method>CONTROL</Method>
//<Command>PTZCONTROL</Command>
//<Params>
////设备的通道ID
//<Channel>2</Channel>
////LEFT RIHGT UP DOWN
//<PTZCmd>LEFT</PTZCmd>
////Start Stop
//<Action>Start</Action>
////1-7
//<Speed>4</Speed>
//</Params>
//</PPVSPMessage>
type ptzControlPacket struct {
	XMLName     xml.Name `xml:"PPVSPMessage"`
	Version     float64  `xml:"Version"`
	Sequence    int64    `xml:"Sequence"`
	CommandType string   `xml:"CommandType"`
	Method      string   `xml:"Method"`
	Command     string   `xml:"Command"`
	Channel     int64    `xml:"Params>Channel"`   //通道ID
	PTZCmd      string   `xml:"Params>PTZCmd"`    //控制命令
	Action      string   `xml:"Params>Action"`    //开始、停止
	Speed       int64    `xml:"Params>Speed"`     //速度
	//ChunkSize   int64    `xml:"Params>ChunkSize"`
//	StartIdx    int64    `xml:"Params>StartIdx"`
}
//UDP客户端 ---> UDP服务端：查询指定通道录像文件回复，若无录像文件则<Params></Params>里面为空
/*
查询成功：
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>1778</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>QUERYRECORDEDFILES</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params>
<RecordedFile>ch0001_00000000335000000 2021-02-01 08:17:54 2021-02-02 09:37:21 553219828 0</RecordedFile> //录像文件名、开始时间、结束时间、文件大小等
<RecordedFile>ch0001_00000000335000100 2021-02-02 09:37:54 2021-02-02 09:47:59 3668116 0</RecordedFile>
</Params>
</PPVSPMessage>

查询失败：
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>1778</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>QUERYRECORDEDFILES</WhichCommand>
<Status>401</Status>
<Description>fail</Description>
<Params/>
</PPVSPMessage>
*/
type responseQueryRecordedFilesPacket struct {
	XMLName       xml.Name `xml:"PPVSPMessage"`
	Version       float64  `xml:"Version"`
	Sequence      int64    `xml:"Sequence"`
	CommandType   string   `xml:"CommandType"`
	WhichCommand  string   `xml:"WhichCommand"`
	Status        int64    `xml:"Status"`
	Description   string   `xml:"Description"`
	RecordedFiles []string `xml:"Params>RecordedFile"` //录像文件列表
}

//UDP服务端 ---> UDP客户端：指定通道录像文件播放请求
/*
<?xml version="1.0" encoding="GB2312" ?>
<PPVSPMessage>
<Version>2.5</Version>
<Sequence>8848</Sequence>
<CommandType>REQUEST</CommandType>
<Method>MEDIA</Method>
<Command>UPLOADFILE</Command>
<Params>
    <Chan>1</Chan>
    <Filename>ch01_00000000005000000</Filename> //录像文件名
    <SeekType>1</SeekType>
    <Seek>0</Seek>
    <SeekSpan>0</SeekSpan>
    <UpServerIP>192.168.1.243</UpServerIP>
    <UpServerPort>8888</UpServerPort>
</Params>
</PPVSPMessage>
*/
type requestUploadFilePacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	Method       string   `xml:"Method"`
	Command      string   `xml:"Command"`
	Chan         int64    `xml:"Params>Chan"`     //通道ID
	Filename     string   `xml:"Params>Filename"` //录像文件名
	SeekType     int64    `xml:"Params>SeekType"`
	Seek         int64    `xml:"Params>Seek"`
	SeekSpan     int64    `xml:"Params>SeekSpan"`
	UpServerIP   string   `xml:"Params>UpServerIP"`
	UpServerPort int64    `xml:"Params>UpServerPort"`
}

//UDP客户端 ---> UDP服务端：指定通道录像文件播放回复
/*
<?xml version="1.0" encoding="GB2312"?>
<PPVSPMessage>
<Version>2.0</Version>
<Sequence>8848</Sequence>
<CommandType>RESPONSE</CommandType>
<WhichCommand>UPLOADFILE</WhichCommand>
<Status>200</Status>
<Description>OK</Description>
<Params/>
</PPVSPMessage>
*/
type responseUploadFilePacket struct {
	XMLName      xml.Name `xml:"PPVSPMessage"`
	Version      float64  `xml:"Version"`
	Sequence     int64    `xml:"Sequence"`
	CommandType  string   `xml:"CommandType"`
	WhichCommand string   `xml:"WhichCommand"`
	Status       int64    `xml:"Status"`
	Description  string   `xml:"Description"`
}
